<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			body {
				margin: 0;
				padding: 0;
			}
			
			.div1 {
				width: 960px;
				display: block;
				background-color: #E5E5E5;
			}
			
			h2 {
				margin: 5px;
				padding: 3px;
			}
			
			.menu-left {
				background-color: lightskyblue;
				padding: 0;
			}
			
			.menu-left>a {
				display: block;
				text-decoration: none;
				text-align: center;
				font-size: 24px;
				cursor: pointer;
				background-color: #E3E3E3;
				width: 100%;
				padding: 5px;
				background-image: -webkit-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -moz-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -o-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0.5, #ffffff), to(#c0c0c0));
				background-image: linear-gradient(#ffffff 50%, #c0c0c0);
			}
			
			.user-add {
				margin-left: 200px;
			}
		</style>
	</head>

	<body>
		<script type="text/javascript">
			jQuery(document).ready(function() {
				$("#add-user").click(function() {
					$("#p1").load("admin/adduser.html .user-add", "", function() {
						$("#submit1").click(function() {
							if ($("#password1").val() != $("#password2").val()) {
								alert("两次输入的密码不一致！");
								return;
							}
							$.ajax({
								type: "post",
								url: "Adduser",
								async: true,
								data: $("#submit").serialize(),
								success: function() {
									alert("用户添加成功！");
									$("#resetform").click();
								}
							});
						});
					});
				});
				$("#view-user").click(function() {
					$("#p1").load("admin/viewuser.html", "", function() {
						$.ajax({
							type: "get",
							url: "Viewuser",
							success: function(data) {
								var obj = $.parseJSON(data);
								$.each(obj, function(name, value) {
									$.each(value, function(index, ele) {
										var s = "";
										var row = ele;
										s = s + "<tr>";
										$.each(ele, function(k, v) {
											s = s + "<td>" + v + "</td>"
										});
										s = s + "<td>" + "<button class='xg'  id='row" + index + "'  data-toggle='modal' data-target='#myModal'>修改</button>" +
											"<button class='sc' id='delete" + index + "'  data-toggle='modal' data-target='#myModal1'>删除</button>" + "</td>" + "</tr>";
										//										alert(s);
										$("#tb-user").append(s);
										$("#row" + index).click(function() {
											//											alert(row.name);
											$("#nam").val(row.name);
											$("#pas").val(row.password);
											$("#gen").val(row.gender);
											$("#confirm").click(function() {
												var name = $("#nam").val();
												var pass = $("#pas").val();
												var gender = $("#gen").val();
												$.ajax({
													type: "post",
													url: "Modify",
													async: true,
													data: $("#submit2").serialize(),
													success: function() {
														$("#close").click();
														alert("修改请求已提交！");
														window.location.reload();
													}
												});
											});
										});
																				$("#delete"+index).click(function() {
																					$("#myModal1").show();
																					$("#goahead").click(function() {
																						var name = row.name;
																						alert(name);
																						$.ajax({
																							type: "post",
																							url: "Delete",
																							async: true,
																							data: "name="+name,
																							success: function() {
																								$("#cancel").click();
																								alert("删除请求已提交！");
																								window.location.reload();
																							}
																						});
																					});
																				});
									});
								});
							}
						});
					});
				});
			});
		</script>
		<div class="div1 center-block">
			<div class="container">
				<div class="row" style="background-color: #C4E3F3; width: 960px;">
					<img src="img/login.png" class="col-lg-2" style="width: 60px; margin-top: 10px;" />
					<h2 class="col-lg-6">学生信息管理信息系统</h2>
					<h4 class="col-lg-4">用户信息</h4>
				</div>
				<div class="row content">
					<div class="col-lg-2 menu-left">
						<a class="" data-toggle="collapse" data-target="#user-manage">用户管理</a>
						<div id="user-manage" class="collapse">
							<a id="add-user">添加用户</a><br /> <a id="view-user">编辑用户</a><br />
							<a>用户设置</a><br />
						</div>
						<a class="" data-toggle="collapse" data-target="#student-manage">学生管理</a>
						<div id="student-manage" class="collapse">
							<a>创建学生</a><br /> <a>删除学生</a><br /> <a>学生设定</a><br />
						</div>
						<a class="" data-toggle="collapse" data-target="#manage">查询管理</a>
						<div id="manage" class="collapse">
							<a>成绩查询</a><br /> <a>课程查询</a><br /> <a>选课查询</a><br />
						</div>
					</div>
					<div class="col-lg-10">
						<p id="p1"></p>
					</div>
				</div>
				<div class="row">
					<div class="col-lg-12" style="background-color: cadetblue; width: 960px;">
						<p>关于我们</p>
					</div>
				</div>
			</div>
		</div>
	</body>

</html>